<?php

namespace App\Http\Middleware;

use App\Admin;
use Closure;
use App\Exceptions\ParameterException;
use Illuminate\Support\Facades\Auth;

class AdminAuth
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @param  string|null  $guard
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
       if( !Auth::guard('admin')->check() ){

           return response()->json(['code'=>4,'msg'=>'qing xian deng lu']);
       }
//        $user = Admin::all()->count();
//
//        if (!($user == 1)) {
//            if (!Auth::guard('admin')->user()->hasPermissionTo('Administer roles & permissions')) // 用户是否具备此权限
//            {
//                return response()->json(['code'=>4,'msg'=>'没有权限']);
//            }
//        }
        return $next($request);
    }
}
